<template>
	<div class="container">
		<div class="jx-return-container">
      <i class="iconfont icon-back" @click="back"></i><span class="cube-title">新建活动</span>
    </div>
    <el-form ref="form" :model="params_list" :rules="rules" label-width="110px" class="jx-form">
      <div class="jx-detail">
        <div class="detail-item">
          <div class="item_2">
            <div class="title">活动类型</div>
            <el-form-item label="活动类型：" prop="type">
              <el-select v-model="params_list.type" placeholder="请选择">
                <el-option label="征集活动-折扣活动" value="1"></el-option>
                <el-option label="征集活动-砍价活动" value="2"></el-option>
                <el-option label="征集活动-团购活动" value="3"></el-option>
                <el-option label="征集活动-秒杀活动" value="4"></el-option>
                <el-option label="自主活动-商品活动" value="5"></el-option>
                <el-option label="自主活动-优惠券活动" value="6"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="征集用户组：" prop="item2">
              <el-select v-model="params_list.item2" placeholder="请选择">
                <el-option label="不限" value="0"></el-option>
                <el-option label="KA组" value="1"></el-option>
                <el-option label="大客户组" value="2"></el-option>
              </el-select>
            </el-form-item>
          </div>
        </div>
        <v-detail1 v-if="(params_list.type == 1) || (params_list.type == 2) || (params_list.type == 3)"></v-detail1>
        <!-- <v-detail2 v-if="params_list.type == 2"></v-detail2>
        <v-detail3 v-if="params_list.type == 3"></v-detail3> -->
        <v-detail4 v-if="params_list.type == 4"></v-detail4> 
        <v-detail5 v-if="params_list.type == 5"></v-detail5> 
        <v-detail6 v-if="params_list.type == 6"></v-detail6>
      </div> 
    </el-form>
    <div class="btn-container">
      <el-button class="jx-btn" type="warning" @click="boo.showDialog = false">取消</el-button>
      <el-button class="jx-btn" type="primary" :loading="boo.saveing" @click="submitRow('form')">确定</el-button>
    </div>
	</div>
</template>

<script>
  import vDetail1 from './new_discount.vue'
  import vDetail4 from './new_spike.vue'
  import vDetail5 from './new_commodity.vue'
  import vDetail6 from './new_coupon.vue'
	export default {
    components: {
      vDetail1,
      vDetail4,
      vDetail5,
      vDetail6,
    },
		data() {
			return {
        boo: {
          loading: false,
        },
        params_list: {
          type: '1',
          item2: '',
        },
        rules: {
          type: [{ required: true, message: '请选择活动类型', trigger: 'change' }],
          item2: [{ required: true, message: '请选择用户组', trigger: 'change' }],
        },
			}
		},
		mounted(){
      let _self = this
    },
		methods: {
      back(){
        history.go(-1)
      },
      
      submitRow(formName){
        let _self = this
				this.$refs[formName].validate((vaild)=>{
					if(vaild){  
            console.log(_self.params_list)
            if(_self.params_list.radio == '') return _self.$message.error('请选择活动要求')
            if(_self.params_list.radio == 2 && _self.params_list.checkactive.length == 0) return _self.$message.error('请选择活动限制条件')
            _self.params_list.checkactive.forEach(function(item){
              if((item == 1) && (_self.params_list.item10 == '')){
                return _self.$message.error('请填写开店时间')
              }else if((item == 2) && (_self.params_list.item11 == '')){
                return _self.$message.error('请填写店铺好评最小分值')
              }else if((item == 3) && (_self.params_list.item12 == '')){
                return _self.$message.error('请填写店铺好评最大分值')
              }else if((item == 10) && (_self.params_list.item13 == '')){
                return _self.$message.error('请填写其他要求')
              }
            })
            if(_self.params_list.radio_discount == '') return _self.$message.error('请选择折扣要求')
            if(_self.params_list.item14 == '') return _self.$message.error('请输入活动说明')
            console.log('1231321312')
            // _self.boo.saveing = true
            // let params = {
            //   name: _self.currentRow.name,
            // }    
            // let success = (res)=>{
            //   res = res.data
            //   if(res.status == 200){
            //     _self.getList()
            //   }else{
            //     _self.$message.error(res.message)
            //   }
            //   _self.boo.saveing = false
            //   _self.boo.showDialog = false
            // }
            // _self.$axios.post(_self.https.checked, params, success)   
					}else{
						return false
					}
				})
      }
    }
	}

</script>
<style scoped lang="sass">
  /deep/ .el-range-editor--small.el-input__inner
    width: 70%
</style>
